import { uploadType } from '@/utils/util'
import bus from '@/utils/eventbus'

export const formConfig = {
	inline: false,
	showBtn: true,
	labelPosition: 'top',
	column: [
		{
			label: '证书编号',
			prop: 'certificateNumber',
			maxlength: '50',
			showWordLimit: true,
			type: 'text',
			span: 8,
			rules: [{ required: true, message: '请输入证书编号' }],
		},
		{
			label: '证书类别',
			prop: 'certificateCategory',
			propName: 'certificateCategoryLabel',
			type: 'remoteSelect',
			code: 'PRACTITIONERS_CERTIFICATE_TYPE',
			api: 'getDictItemList',
			dataType: 'number',
			filterKey: 'value',
			multiple: false,
      editDisabled:true,
			span: 8,
			rules: [{ required: true, message: '请选择证书类别' }],
			change: (item, form, value) => {
        console.log(item,'item--ddd')
				bus.emit('remote-search-params-certificateGrade', item.description)
			},
		},
		{
			label: '证书等级',
			prop: 'certificateGrade',
			propName: 'certificateGradeLabel',
			type: 'remoteSelect',
			api: 'getDictItemList',
			dataType: 'string',
			filterKey: 'value',
			multiple: false,
			span: 8,
			rules: [{ required: true, message: '请选择证书等级' }],
		},
		{
			label: '注册地',
			prop: 'registrationLocation',
			type: 'input',
			span: 8,
		},
		{
			label: '取得时间',
			prop: 'certificateAcquisitionTime',
			type: 'date',
			format: 'YYYY年MM月DD日',
			valueFormat: 'YYYY-MM-DD',
			span: 8,
		},
		{
			label: '到期时间',
			prop: 'certificateExpirationTime',
			type: 'date',
			format: 'YYYY年MM月DD日',
			valueFormat: 'YYYY-MM-DD',
			span: 8,
		},
		{
			label: '文件',
			prop: 'file',
			type: 'upload',
			fileType: uploadType.fileMetaType,
			listType: 'picture-card',
			labelPosition: 'top',
			showFileList: true,
			limit: 4,
			disabled: true,
			multiple: true,
			changeField: true,
			span: 24,
			rules: [{ required: true, message: '请上传证书文件' }],
		},
	],
}

export const tableConfig = {
	stripe: true,
	border: true,
	columns: [
		{ label: '证书类别', prop: 'certificateCategoryLabel' },
		{ label: '证书编号', prop: 'certificateNumber' },
		{ label: '证书等级', prop: 'certificateGradeLabel' },
		{ label: '注册地', prop: 'registrationLocation' },
		{ label: '取得时间', prop: 'certificateAcquisitionTime' },
		{ label: '到期时间', prop: 'certificateExpirationTime' },
		{ label: '文件', prop: 'file', custome: 'file' },
		{
			label: '操作',
			prop: 'menu',
			width: 300,
			fixed: 'right',
		},
	],
}

export const api = {
	index: 'view_dpFoundationPractitionersCertificate_page',
	add: 'view_dpFoundationPractitionersCertificate_add',
	edit: 'view_dpFoundationPractitionersCertificate_edit',
	delete: 'view_dpFoundationPractitionersCertificate_del',
}
export const baseConfig = {
	pageName: '职业/执业证书',
	dictcodes: ['PRACTITIONERS_CERTIFICATE_TYPE'],
	rowKey: 'id',
	addLabel: '新增',
	tipLabel: 'certificateNumber',
	exportMqTopic: '/ning/export/',
	api,
	auth: api,
	menuBtn: [
		{
			icon: 'editor',
			label: '编辑',
			type: 'primary',
			operate: 'edit',
			auth: 'sys_role_edit',
			text: true,
			show: true,
		},
		{
			icon: 'delete',
			label: '删除',
			type: 'danger',
			operate: 'delete',
			auth: 'sys_role_del',
			text: true,
			show: true,
		},
	],
	saveFormate: async (form) => {
		return new Promise((resolve, reject) => {
			resolve(form)
		})
	},
	dialogConfig: {
		width: '55%',
	},
	formConfig,
	tableConfig,
}
